package com.songlin.houxin.admin.api.converter;


import com.songlin.houxin.admin.api.dto.OrderUpdateDTO;
import com.songlin.houxin.admin.api.entity.Order;
import com.songlin.houxin.admin.api.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author jinYuLinLang
 * @version 1.0.0
 * @ClassName OrderConverter.java
 * @Description <p>订单转换类</p>
 * @createTime 2022-03-06 10:30:00
 */
@Mapper
public interface OrderConverter {

    OrderConverter INSTANCE = Mappers.getMapper(OrderConverter.class);


    /**
     * @Mappings({
     * @Mapping(source = "birthday", target = "birth"),
     * @Mapping(source = "birthday", target = "birthDateFormat", dateFormat = "yyyy-MM-dd HH:mm:ss"),
     * @Mapping(target = "birthExpressionFormat", expression = "java(org.apache.commons.lang3.time.DateFormatUtils.format(person.getBirthday(),\"yyyy-MM-dd HH:mm:ss\"))"),
     * @Mapping(source = "user.age", target = "age"),
     * })
     */
    @Mapping(target = "channelName", ignore = true)
    OrderVO toOrderVO(Order order);

    /**
     * 转成list
     *
     * @param orders 订单列表
     * @return
     */
    List<OrderVO> toOrderVOList(List<Order> orders);

    /**
     * 订单更新入参新转换成订单表信息
     *
     * @param dto
     * @return
     */
    Order toOrder(OrderUpdateDTO dto);
}
